import { IPSSysMsgTempl } from '../msg/ipssys-msg-templ';
import { IPSLanguageRes } from '../res/ipslanguage-res';
import { IPSWFLink } from './ipswflink';
import { IPSWFProcess } from './ipswfprocess';
import { IPSWFProcessParam } from './ipswfprocess-param';
import { IPSWFWorkTime } from './ipswfwork-time';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSWFProcessImpl extends PSModelObjectImpl implements IPSWFProcess {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get height(): number {
    return this.M.height;
  }

  get leftPos(): number {
    return this.M.leftPos;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected namepslanguageres: IPSLanguageRes | null = null;

  getNamePSLanguageRes(): IPSLanguageRes | null {
    if (this.namepslanguageres != null) return this.namepslanguageres;
    const value = this.M.getNamePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.namepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getNamePSLanguageRes') as IPSLanguageRes;
    return this.namepslanguageres;
  }

  get namePSLanguageRes(): IPSLanguageRes | null {
    return this.getNamePSLanguageRes();
  }

  getNamePSLanguageResMust(): IPSLanguageRes {
    const value = this.getNamePSLanguageRes();
    if (value == null) {
      throw new Error('未指定名称语言资源');
    }
    return value;
  }

  protected pssysmsgtempl: IPSSysMsgTempl | null = null;

  getPSSysMsgTempl(): IPSSysMsgTempl | null {
    if (this.pssysmsgtempl != null) return this.pssysmsgtempl;
    const value = this.M.getPSSysMsgTempl;
    if (value == null) {
      return null;
    }
    this.pssysmsgtempl = this.getPSModel4('msg.IPSSysMsgTempl', value, 'getPSSysMsgTempl') as IPSSysMsgTempl;
    return this.pssysmsgtempl;
  }

  get psSysMsgTempl(): IPSSysMsgTempl | null {
    return this.getPSSysMsgTempl();
  }

  getPSSysMsgTemplMust(): IPSSysMsgTempl {
    const value = this.getPSSysMsgTempl();
    if (value == null) {
      throw new Error('未指定通知消息模板');
    }
    return value;
  }

  protected pswflinks: IPSWFLink[] | null = null;

  getPSWFLinks(): IPSWFLink[] | null {
    if (this.pswflinks == null) {
      this.pswflinks = this.fillChildListModel(this.M.getPSWFLinks, 'wf.IPSWFLink') as IPSWFLink[];
    }
    return this.pswflinks;
  }

  get psWFLinks(): IPSWFLink[] | null {
    return this.getPSWFLinks();
  }

  findPSWFLink(objKey: any): IPSWFLink | null {
    return this.getPSModel5('wf.IPSWFLink', this.getPSWFLinks(), objKey) as IPSWFLink;
  }

  protected pswfprocessparams: IPSWFProcessParam[] | null = null;

  getPSWFProcessParams(): IPSWFProcessParam[] | null {
    if (this.pswfprocessparams == null) {
      this.pswfprocessparams = this.fillChildListModel(this.M.getPSWFProcessParams, 'wf.IPSWFProcessParam') as IPSWFProcessParam[];
    }
    return this.pswfprocessparams;
  }

  get psWFProcessParams(): IPSWFProcessParam[] | null {
    return this.getPSWFProcessParams();
  }

  findPSWFProcessParam(objKey: any): IPSWFProcessParam | null {
    return this.getPSModel5('wf.IPSWFProcessParam', this.getPSWFProcessParams(), objKey) as IPSWFProcessParam;
  }

  protected pswfworktime: IPSWFWorkTime | null = null;

  getPSWFWorkTime(): IPSWFWorkTime | null {
    if (this.pswfworktime != null) return this.pswfworktime;
    const value = this.M.getPSWFWorkTime;
    if (value == null) {
      return null;
    }
    this.pswfworktime = this.getPSModel4('wf.IPSWFWorkTime', value, 'getPSWFWorkTime') as IPSWFWorkTime;
    return this.pswfworktime;
  }

  get psWFWorkTime(): IPSWFWorkTime | null {
    return this.getPSWFWorkTime();
  }

  getPSWFWorkTimeMust(): IPSWFWorkTime {
    const value = this.getPSWFWorkTime();
    if (value == null) {
      throw new Error('未指定流程工作时间');
    }
    return value;
  }

  get timeout(): number {
    return this.M.timeout;
  }

  get timeoutField(): string {
    return this.M.timeoutField;
  }

  get timeoutType(): 'MINUTE' | 'HOUR' | 'DAY' | 'WORKDAY' {
    return this.M.timeoutType;
  }

  get topPos(): number {
    return this.M.topPos;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userData(): string {
    return this.M.userData;
  }

  get userData2(): string {
    return this.M.userData2;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get wFProcessType(): 'START' | 'END' | 'PROCESS' | 'INTERACTIVE' | 'EMBED' | 'EXCLUSIVEGATEWAY' | 'INCLUSIVEGATEWAY' | 'PARALLELGATEWAY' | 'CALLORGACTIVITY' {
    return this.M.wFProcessType;
  }

  get wFStepValue(): string {
    return this.M.wFStepValue;
  }

  get width(): number {
    return this.M.width;
  }

  get asynchronousProcess(): boolean {
    return this.M.asynchronousProcess;
  }

  get enableTimeout(): boolean {
    return this.M.enableTimeout;
  }

  get startProcess(): boolean {
    return this.M.startProcess;
  }

  get terminalProcess(): boolean {
    return this.M.terminalProcess;
  }

  get cls(): string {
    return 'PSWFProcessImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'wf.IPSWFProcess') return true;
    return super.instanceof(cls);
  }
}
